import 'package:flutter/material.dart';

import 'package:get/get.dart';
import 'package:getwidget/colors/gf_color.dart';
import 'package:getwidget/components/card/gf_card.dart';
import 'package:getwidget/components/checkbox/gf_checkbox.dart';
import 'package:getwidget/size/gf_size.dart';
import 'package:getwidget/types/gf_checkbox_type.dart';

import '../controllers/gfcheckbox_controller.dart';

class GfcheckboxView extends GetView<GfcheckboxController> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('复选框'),
        centerTitle: true,
      ),
      body: Container(
        margin: EdgeInsets.all(10),
        child: ListView(
          children: [
            Obx(() {
              return Row(
                mainAxisAlignment: MainAxisAlignment.center,
                children: [
                  GFCheckbox(
                    size: GFSize.SMALL,
                    activeBgColor: GFColors.DANGER,
                    onChanged: (value) {
                      controller.isChecked.value = value;
                    },
                    value: controller.isChecked.value,
                  ),
                  SizedBox(width: 10,),
                  Text(
                    '同意',
                    style: Theme.of(context).textTheme.headline6
                  )
                ],
              );
            }),

            Obx(() {
              return GFCard(
                content: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: <Widget>[
                    GFCheckbox(
                      size: GFSize.SMALL,
                      activeBgColor: GFColors.DANGER,
                      onChanged: (value) {
                        controller.isChecked.value = value;
                      },
                      value: controller.isChecked.value,
                      inactiveIcon: null,
                    ),
                    GFCheckbox(
                      activeBgColor: GFColors.SECONDARY,
                      onChanged: (value) {
                        controller.isChecked.value = value;
                      },
                      value: controller.isChecked.value,
                      inactiveIcon: null,
                    ),
                    GFCheckbox(
                      size: GFSize.LARGE,
                      activeBgColor: GFColors.SUCCESS,
                      onChanged: (value) {
                        controller.isChecked.value = value;
                      },
                      value: controller.isChecked.value,
                      inactiveIcon: null,
                    ),
                  ],
                ),
              );
            }),

            Obx(() {
              return GFCard(
                content: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: <Widget>[
                    GFCheckbox(
                      size: GFSize.SMALL,
                      activeBgColor: GFColors.DANGER,
                      type: GFCheckboxType.circle,
                      onChanged: (value) {
                        controller.isChecked.value = value;
                      },
                      value: controller.isChecked.value,
                      inactiveIcon: null,
                    ),
                    GFCheckbox(
                      type: GFCheckboxType.circle,
                      activeBgColor: GFColors.SECONDARY,
                      onChanged: (value) {
                        controller.isChecked.value = value;
                      },
                      value: controller.isChecked.value,
                    ),
                    GFCheckbox(
                      activeBgColor: GFColors.SUCCESS,
                      size: GFSize.LARGE,
                      type: GFCheckboxType.circle,
                      onChanged: (value) {
                        controller.isChecked.value = value;
                      },
                      value: controller.isChecked.value,
                      inactiveIcon: null,
                    ),
                  ],
                ),
              );
            }),

            Obx(() {
              return GFCard(
                content: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: <Widget>[
                    GFCheckbox(
                      size: GFSize.SMALL,
                      type: GFCheckboxType.custom,
                      onChanged: (value) {
                        controller.isChecked.value = value;
                      },
                      value: controller.isChecked.value,
                      inactiveIcon: null,
                    ),
                    GFCheckbox(
                      type: GFCheckboxType.square,
                      activeBgColor: GFColors.SECONDARY,
                      activeIcon: Icon(Icons.sentiment_satisfied),
                      onChanged: (value) {
                        controller.isChecked.value = value;
                      },
                      value: controller.isChecked.value,
                      inactiveIcon: Icon(Icons.sentiment_dissatisfied),
                    ),
                    GFCheckbox(
                      size: GFSize.MEDIUM,
                      type: GFCheckboxType.custom,
                      onChanged: (value) {
                        controller.isChecked.value = value;
                      },
                      value: controller.isChecked.value,
                      customBgColor: GFColors.INFO,
                    ),
                  ],
                ),
              );
            })
            
          ],
        ),
      ),
    );
  }
}
